﻿package Naruto.Bloods {
	
	import flash.display.MovieClip;
	import flash.display.*;
//	import flash.display.Stage;
	
	public class Blood extends MovieClip {
		private var _stage:Stage;
		private var _container:Sprite;	
		private var _container2:Sprite;	//Ckl
		private var _container3:Sprite;	//Boss container
		
		private var _bloodframe:Bloodframe;	//血框
		private var _bloodframewidth:Number;//血框宽度
		private var _bloodgreen:Bloodgreen; //血条
		private var _BossBloodGreen:Bloodgreen;	//BOSS血条
		private var _health:Number;			//血量
		private var _BossHealth:int;		//Boss血量
		
		private var _bloodframe2:Bloodframe;//查克拉框
		private var _cklblue:Cklblue;		//查克拉条
		private var _ckl:int;				//查克拉量
	
		public function Blood(stage:Stage){
			this._stage = stage;
			this._container = new Sprite();	//Sprite
			this._container.x = 50;
			this._container.y = 40;
			
			this._bloodframe = new Bloodframe();
			this._bloodgreen = new Bloodgreen();
			this._bloodframewidth = this._bloodframe.width;			
			
			addBlood();
			
			this._container2 = new Sprite();
			this._container2.x = 50;
			this._container2.y = 53;
			
			this._bloodframe2 = new Bloodframe();
			this._cklblue = new Cklblue();
			
			addBlood2();
		}
		
		public function addBossBlood(){
			this._container3 = new Sprite();	//Sprite
			this._container3.x = this._stage.stageWidth/2 - this._container.width/2;
			this._container3.y = 40;
			
			this._bloodframe = new Bloodframe();
			this._BossBloodGreen = new Bloodgreen();
			this._bloodframewidth = this._bloodframe.width;			
			
			addBlood3();
		}
		
		public function addBlood(){
			this._stage.addChild(_container);
			_container.addChild(_bloodframe);
			_container.addChildAt(_bloodgreen,0);	//血条位于血框底下
		} 
		
		public function addBlood2(){
			this._stage.addChild(_container2);
			_container2.addChild(_bloodframe2);
			_container2.addChildAt(_cklblue,0);	//查克拉条位于查克拉框底下
		}
		
		public function addBlood3(){
			this._stage.addChild(_container3);
			_container3.addChild(_bloodframe);
			_container3.addChildAt(_BossBloodGreen,0);	//BOSS血条位于血框底下
		}
		
		public function changeHealth(health:Number){  //health为具体生命数值 (0-100)
			
			this._health = health;
			//trace(this._health);
			this._bloodgreen.width = _bloodframewidth * (health/100);
		}
		public function changeBossHealth(health:Number){  
			
			this._BossHealth = health;
			//trace(this._health);
			this._BossBloodGreen.width = _bloodframewidth * (health/100);
		}
		
		public function changeCkl(ckl:int){
			this._ckl = ckl;
			this._cklblue.width = _bloodframewidth * (ckl/100);
		}
		
		public function getHealth(){
			return this._health;
		}
		
		public function getCkl(){
			return this._ckl;
		}
	} 	
}